Skip to content

Add MCP Apps support for static_map_image_tool#109

Merged
mattpodwysocki merged 16 commits intomainfrom
add-mcp-apps-static-map
Feb 23, 2026
Merged

Add MCP Apps support for static_map_image_tool#109
mattpodwysocki merged 16 commits intomainfrom
add-mcp-apps-static-map

Conversation

@mattpodwysocki
Copy link
Contributor

@mattpodwysocki mattpodwysocki commented Feb 2, 2026

Summary

Implements MCP Apps support for `static_map_image_tool`, enabling interactive map preview in compatible hosts (Claude Desktop, VS Code Insiders, etc.).

Screenshots

Inline view (with fullscreen button):
Screenshot 2026-02-18 at 15 57 13

Fullscreen view:
Screenshot 2026-02-18 at 15 56 46

Changes

Dependencies

  • Add `@modelcontextprotocol/ext-apps@^1.0.1`
  • Upgrade `@modelcontextprotocol/sdk` to `^1.26.0` with patch softening validation errors to warnings

Tool Enhancement

  • Refactored `StaticMapImageTool` to return URL directly instead of fetching and base64-encoding
  • Added `meta` property with `resourceUri` and CSP configuration
  • Added `viewUUID` to tool response `_meta` so the host routes the result to the correct UI panel
  • Maintains backward compatibility with MCP-UI via `createUIResource()`

MCP Apps UI

  • Created `StaticMapUIResource` serving interactive HTML via `ui://mapbox/static-map/index.html`
  • Inline MCP Apps protocol client (avoids CSP issues with external imports)
  • Sends `ui/notifications/size-changed` after image loads to fit the panel to the image height
  • Fullscreen toggle button (shown when host supports fullscreen mode)
  • Handles `ui/notifications/host-context-changed` to re-fit on returning from fullscreen

Infrastructure

  • Enhanced `BaseTool` with `meta` property for MCP Apps metadata
  • Updated `index.ts` to use `registerAppResource` for UI resources (with `as any` cast — the type incorrectly requires `_meta` at registration time, but per the ext-apps example CSP belongs only in the response)
  • Added `StaticMapUIResource` to resource registry

Why URL instead of base64?

  1. No server-side fetching: Eliminates unnecessary API calls
  2. MCP Apps compatibility: URL fetched by client with proper CSP
  3. Better performance: Avoids encoding/decoding overhead

Testing

  • ✅ All 610 tests passing
  • ✅ Updated tests to expect URL text content
  • ✅ Lint and format clean
  • ✅ Verified in Claude Desktop (inline + fullscreen)

Related

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants